package com.kede.config;


import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;
/***
 ** @Author:Pr.li
 ** @Description:
 ** @Date: create in 2023/5/10 16:37
 ***/
@Configuration
public class DataSourceConfig {
    @Primary
    @Bean(value = "primaryDataSource")
    @ConfigurationProperties("spring.datasource.druid.primary") //spring.datasource.druid.primary为yml文件中数据源路径:primary
    public DataSource dataSourceOne(){
        return DruidDataSourceBuilder.create().build();
    }

    @Bean(value = "secondDataSource")
    @ConfigurationProperties("spring.datasource.druid.secondary")//spring.datasource.druid.secondary为yml文件中数据源路径：secondary
    public DataSource dataSourceTwo(){
        return DruidDataSourceBuilder.create().build();
    }
}
